import Vue from 'vue'
import Vuex from 'vuex'
import states from "vuex-persistedstate"


Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    token: "",
    user: {},
    clazz: {},
  },
  mutations: {
    setUser(state, user) {
      this.state.user = user
    },
    setToken(state, token) {
      this.state.token = token
    },
    setClazz(state, clazz) {
      this.state.clazz = clazz
    }
  },
  actions: {
    setUser({commit}, user) {
      // console.log(user);
      commit("setUser", user)
    },
    setToken({commit}, token) {
      // console.log(user);
      commit("setToken", token)
    },
    setClazz({commit}, clazz) {
      commit("setClazz", clazz);
    }
  },
  modules: {},
  plugins: [states()]
})
